package com.newegg.app.qec.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.newegg.app.qec.R;
import com.newegg.app.qec.util.BaseActivity;
import com.newegg.app.qec.util.Constants;

/**
 * Created by Allen on 2017/12/13.
 */
public class SetActivity extends BaseActivity implements View.OnClickListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set);
        ImageView back = (ImageView) findViewById(R.id.img_back);
        TextView name = (TextView) findViewById(R.id.title_name);
        Button log_off_btn = (Button) findViewById(R.id.log_off_btn);
        name.setText("设置");
        back.setOnClickListener(this);
        log_off_btn.setOnClickListener(this);

        if (Constants.getLoginByName(SetActivity.this, "LoginState")) {
            log_off_btn.setVisibility(View.VISIBLE);
        } else {
            log_off_btn.setVisibility(View.GONE);
            log_off_btn.setClickable(false);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.log_off_btn:
                Constants.clearLoginByName(SetActivity.this, "LoginState");
                //发送广播更新我的页面数据
                sendBroadcast(new Intent("QEC").putExtra("QEC", 1));
                SetActivity.this.finish();
                break;
        }
    }
}
